package com.newlink.building.userinfo.mvp

import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.model.bean.Base_ChangePasswordBean
import com.newlink.building.common_base.utils.logDebug
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_AccountInformationChangePasswordContract
import com.newlink.building.userinfo.mvp.model.Module_UserInfo_AccountInformationChangePasswordModel

/**
 * @author wangyang
 * @date 2022/10/27
 * @description 我的——账户信息——修改密码页面的Presenter
 */
class Module_UserInfo_AccountInformationChangePasswordPresenter :
    BasePresenter<Module_UserInfo_AccountInformationChangePasswordContract.Model, Module_UserInfo_AccountInformationChangePasswordContract.View>(),
    Module_UserInfo_AccountInformationChangePasswordContract.Presenter {

    override fun createModel(): Module_UserInfo_AccountInformationChangePasswordContract.Model? {
        return Module_UserInfo_AccountInformationChangePasswordModel()
    }

    override fun changePassword(token: String, changePasswordBean: Base_ChangePasswordBean) {
        mModel?.changePassword(token, changePasswordBean)?.ss(mModel, mView) {
            logDebug<Module_UserInfo_AccountInformationChangePasswordPresenter>("changePassword response ->  ${it?.data}")
            if (it?.code == 200) {
                mView?.changePasswordSuccess()
            } else {
                mView?.changePasswordFail(it?.data.orEmpty())
            }
        }
    }
}